package com.nstar.hacocwebfx.view.components
{
	import com.nstar.thirdparty.cssloader.CSSParser;
	
	import mx.containers.ControlBar;
	import mx.controls.Alert;

	public class AlertHacoc extends Alert
	{
		public function AlertHacoc()
		{
			//TODO: implement function
			super();
			Alert.yesLabel 		= "是";
			Alert.noLabel 		= "否";
			Alert.okLabel 		= "确定";
			Alert.cancelLabel 	= "取消";
			Alert.buttonHeight 	= 25;
		}
		
		private static function getInstance():AlertHacoc{
			return new AlertHacoc();
		}
		
		public static function showInfo(text:String,title:String = "提示信息"):Alert{
			var alert:AlertHacoc = AlertHacoc.getInstance();
			return alert.info(text,title);
		}
		
		public static function showError(text:String,title:String = "提示信息"):Alert{
			var alert:AlertHacoc = AlertHacoc.getInstance();
			return alert.error(text,title);
		}
		
		public static function showConfirm(text:String,title:String = "提示信息",
			closeHandler:Function = null):Alert{
			var alert:AlertHacoc = AlertHacoc.getInstance();
			return alert.confirm(text,title,closeHandler);
		}
		
		//提示信息
		private function info(text:String,title:String):Alert{
			var alert:Alert = Alert.show(text,title,Alert.OK,null,null,
				CSSParser.getStyle(".alert","alertInfoIcon"));
			alert.titleIcon = CSSParser.getStyle(".alert","alertTitleIcon");
			return alert;
		}
		
		//异常提示
		private function error(text:String,title:String):Alert{
			var alert:Alert = Alert.show(text,title,Alert.OK,null,null,
				CSSParser.getStyle(".alert","alertErrorIcon"));
			alert.titleIcon = CSSParser.getStyle(".alert","alertTitleIcon");
			return alert;
		}		
		
		//确认提示
		private function confirm(text:String,title:String,closeHandler:Function = null):Alert{
			var alert:Alert = Alert.show(text,title,Alert.YES | Alert.NO,
				null,closeHandler,CSSParser.getStyle(".alert","alertConfirmIcon"));
			alert.titleIcon = CSSParser.getStyle(".alert","alertTitleIcon");
			return alert;
		}		
		
	}
}